package com.jxs.android.weiget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.telecom.weixi.R;

/**
 * @Des this View used to search result pages
 * @author Jiangxs
 */
public class BuCustomerView extends LinearLayout {

	LinearLayout container;
	private TextView custName;
	private TextView custType;
	private TextView custIncharge;
	private TextView custProNum;
	private TextView custAddr;
	private TextView custCard;
	private TextView cardNum;

	private View partExtra;

	public BuCustomerView(Context context) {
		this(context, null);
	}

	public BuCustomerView(Context context, AttributeSet attrs) {
		super(context, attrs);

		LayoutInflater flater = LayoutInflater.from(context);
		flater.inflate(R.layout.bu_search_customer_view, this);
		container = (LinearLayout) findViewById(R.id.cust_container);
		custName = (TextView) findViewById(R.id.cust_name);
		custType = (TextView) findViewById(R.id.cust_type);
		custIncharge = (TextView) findViewById(R.id.cust_incharge);
		custProNum = (TextView) findViewById(R.id.cust_pro_num);
		custAddr = (TextView) findViewById(R.id.cust_addr);
		custCard = (TextView) findViewById(R.id.cust_card);
		cardNum = (TextView) findViewById(R.id.cust_cardnum);
		partExtra = findViewById(R.id.cust_part_extra);
		// test();
	}

	@Deprecated
	void test() {
		setCustName("薛淑芬");
		setCustType("公共");
		setCustInCharge("陆涛");
		setCustProNum("12 【CDMA固话1 宽带1 其他8】");
		setCustAddr("北京市海淀区");
		setCustCard("身份证");
		setCustCardNum("12345");
	}

	public void fixContent(String name, String type, String manager, String proNum) {
		setCustName(name);
		setCustType(type);
		setCustInCharge(manager);
		setCustProNum(proNum);
		partExtra.setVisibility(View.GONE);
	}

	public void fixContent(String name, String type, String manager) {
		setCustName(name);
		setCustType(type);
		setCustInCharge(manager);
		findViewById(R.id.cust_pro_num_ll).setVisibility(View.GONE);
		partExtra.setVisibility(View.GONE);
	}

	public void fixContent(String name, String type, String manager, String proNum, String addr, String card, String cardNum) {
		setCustName(name);
		setCustType(type);
		setCustInCharge(manager);
		setCustProNum(proNum);
		setCustAddr(addr);
		setCustCard(card);
		setCustCardNum(cardNum);
		partExtra.setVisibility(View.VISIBLE);
	}

	public BuCustRowView addRow(String title, String content) {
		BuCustRowView row = new BuCustRowView(getContext(), false);
		row.initContent(title, content);
		container.addView(row);
		return row;
	}

	public BuCustRowView addRow(String title, String content, boolean flag) {
		BuCustRowView row = new BuCustRowView(getContext(), false);
		row.initContent(title, content, flag);
		container.addView(row);
		return row;
	}

	public BuCustRowView addRowSplit(String title, String content) {
		BuCustRowView row = new BuCustRowView(getContext(), true);
		row.initContent(title, content);
		container.addView(row);
		return row;
	}

	public void setCustName(String value) {
		custName.setText(value);
	}

	public void setCustType(String value) {
		custType.setText(value);
	}

	public void setCustInCharge(String value) {
		custIncharge.setText(value);
	}

	public void setCustProNum(String value) {
		custProNum.setText(value);
	}

	public void setCustAddr(String value) {
		custAddr.setText(value);
	}

	public void setCustCard(String value) {
		custCard.setText(value);
	}

	public void setCustCardNum(String value) {
		cardNum.setText(value);
	}

}